package com.usian.admin.controller;


import com.usian.admin.service.AdSensitiveService;
import com.usian.apis.admin.AdSensitiveControllerApi;
import com.usian.model.admin.dtos.SensitiveDto;
import com.usian.model.admin.pojos.AdSensitive;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/Sensitive")
public class AdSensitiveController implements AdSensitiveControllerApi {
    @Autowired
    private AdSensitiveService adSensitiveService;

    /**
     * 袁浩 2022-6-23
     * 根据关键字进行敏感词分页模糊查询
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @Override
    public ResponseResult findByName(@RequestBody SensitiveDto dto) {
        return adSensitiveService.findByName(dto);
    }

    /**
     * 袁浩 2022-6-23
     * 敏感词新增
     * @param adSensitive
     * @return
     */
    @PostMapping("/save")
    @Override
    public ResponseResult save(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.insert(adSensitive);
    }

    /**
     *袁浩 2022-6-23
     * 敏感词修改
     * @param adSensitive
     * @return
     */
    @PostMapping("/update")
    @Override
    public ResponseResult update(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.update(adSensitive);
    }

    /**
     * 袁浩 2022-6-23
     * 根据id删除敏感词
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    @Override
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return adSensitiveService.deleteById(id);
    }
}
